package cc.magicjson.data.operation.router.db.datasource;

import javax.sql.DataSource;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class DataSourceHolder {
    @Setter
    private static DataSource master;
    @Setter
    private static DataSource slave;

    public static DataSource getMaster() {
        if (master == null) {
            throw new IllegalStateException("Master DataSource not initialized");
        }
        return master;
    }

    public static DataSource getSlave() {
        if (slave == null) {
            throw new IllegalStateException("Slave DataSource not initialized");
        }
        return slave;
    }
}
